import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;

/**
 * @Question no2
 * @Date 2023/2/11 11:52
 * @Solution
 */
public class no2 {
    static int num=0;
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n=scanner.nextInt();
        int m=scanner.nextInt();
        List<int[]> boom=new ArrayList<>();//炸雷
        for(int i=0;i<n;i++) {
            int[] b=new int[4];
            b[3]=0;
            for(int f=0;f<3;f++) {
                b[f]=scanner.nextInt();
            }
            boom.add(b);
        }
        //将雷排序
        boom.sort(new Comparator<int[]>() {
            @Override
            public int compare(int[] o1, int[] o2) {
                return o1[0]-o2[0];
            }
        });
        for(int i=0;i<m;i++) {
            int[] b=new int[3];
            for(int f=0;f<3;f++) {
                b[f]=scanner.nextInt();
            }
            work(b[0],b[1],b[2],boom);
        }
        System.out.println(num);
    }
    public static void work(int x1,int y1,int r1,List<int[]> boom) {
        if(boom.size()==0) {
            return;
        }
        //确定搜索范围，如果|x1-x2|>r，就可以不管y了，直接忽略.所以实际搜索范围是[x1-r,x1+r],通过二分快速找到边界
        int beginDex=0,endDex=0;
        int l=0;
        int r=boom.size()-1;
        //找左边界
        while(l<r) {
            beginDex=(l+r)/2;
            if(boom.get(beginDex)[0]>x1-r1) {
                r=beginDex-1;
            } else {
                l=beginDex+1;
            }
        }
        beginDex=l;
        //找右边界
        l=0;
        r=boom.size()-1;
        while(l<r) {
            endDex=(l+r)/2;
            if(boom.get(endDex)[0]>x1+r1) {
                r=endDex-1;
            } else {
                l=endDex+1;
            }
        }
        endDex=r;
        for(int i=beginDex;i<=endDex;i++) {
            int[] cur=boom.get(i);
            //1为爆炸点的坐标
            if(cur[3]==0&&Math.sqrt(Math.pow(x1-cur[0],2)+Math.pow(y1-cur[2],2))<=r1) {
                boom.get(i)[3]=1;
                num++;
                //如果炸了则扫描周围是否有范围内的炸弹
                work(cur[0],cur[1],cur[2],boom);
            }
        }
        return;
    }
}
